package com.manager.car.service;

import java.util.ArrayList;
import java.util.List;

import com.manager.car.dao.ISubscribeDao;
import com.manager.car.po.SubscribeInfo;
import com.manager.car.util.PageBean;



public class SubscribeServiceImpl implements ISubscribeService {
  private ISubscribeDao subDao;
	public PageBean<SubscribeInfo> findAll(SubscribeInfo courseType, int pageNum, int pageSize) {
		// 1 条件查询
		// 1.1 拼凑查询条件
		StringBuilder builder = new StringBuilder();
		// 1.2 拼凑实际参数 , 可以重复，顺序 --> List
		List<Object> paramsList = new ArrayList<Object>();
		
		// 条件 , 格式：" and ..? and ..."
		String condition = builder.toString();
		// 实际参数
		Object[] params = paramsList.toArray();
		// //////////////////////////////////////////////////////////
		// 2分页
		// 2.1 总记录数
		int totalRecord = this.subDao.getTotalRecord("", null);
		// 2.2 创建对象
		PageBean<SubscribeInfo> pageBean = new PageBean<SubscribeInfo>(pageNum,
		pageSize, totalRecord);
		// 2.3 分页数据
		List<SubscribeInfo> data = this.subDao.findAll("",
		null, pageBean.getStartIndex(), pageBean.getPageSize());
		//为data集合赋值
		pageBean.setData(data);
		return pageBean;
	}
	//添加
	public void addSub(SubscribeInfo sub) {
		subDao.addSub(sub);
		
	}
	//修改
	public void updateSub(SubscribeInfo sub) {
		subDao.updateSub(sub);
		
	}
	//删除
	public void deleteSub(Integer id) {
		subDao.deleteSub(id);
		
	}
	//根据ID查询
	public SubscribeInfo queryById(Integer id) {
		
		return subDao.queryBysubId(id);
	}
	public List<SubscribeInfo> queryAll(String name, int limit, int page) {
		
		return this.subDao.queryAll(name, limit, page);
	}
	public int getcount(String name, int limit, int page) {
		// TODO Auto-generated method stub
		return this.subDao.getcount(name, limit, page);
	}
	public ISubscribeDao getSubDao() {
		return subDao;
	}
	public void setSubDao(ISubscribeDao subDao) {
		this.subDao = subDao;
	}
	
	

}
